#include<stdio.h>
#include<malloc.h>
void quick_sort(long long int num[],long long int low, long long int high )
{
    long long int i,j,temp;
    long long int tmp;
    i = low;
    j = high;
    tmp = num[low];   //任命为中间分界线，左边比他小，右边比他大,通常第一个元素是基准数
    if(i > j)  //如果下标i大于下标j，函数结束运行
    {
        return;
    }
    while(i != j)
    {
        while(num[j] >= tmp && j > i)   
        {
            j--;
        }
        while(num[i] <= tmp && j > i)
        {
            i++;
        }
        if(j > i)
        {
            temp = num[j];
            num[j] = num[i];
            num[i] = temp;
        }
    }
    num[low] = num[i];
    num[i] = tmp;
    quick_sort(num,low,i-1);
    quick_sort(num,i+1,high);
}

int main()
{
    long long int n,m;
    while((scanf("%lld%lld",&n,&m))!=EOF)
    {
    long long int a[2000010]={0},i,j,cnt=0,z=0;
    for(i=1;i<=n;i++)
    {
    scanf("%lld",&a[i]);
    
    }
    quick_sort(a,1,n);
    for(i=1;i<=n;i++)
    {
         if(a[i]==a[i-1]&&a[i]!=a[j]&&a[i]!=m)
        {
            cnt=cnt+z;
            continue;
        }
        if(a[i]==a[i-1]&&a[i]==a[j]&&a[i]!=m)
        {
            cnt=cnt+--z;
            continue;
        } 
        if(a[i]==m)
        {
        cnt++;
        continue;
        }   
        z=0;
        for(j=i+1;j<=n;j++)
        {
            if(a[i]+a[j]==m)
            {
            z++;
            if(a[j+1]!=a[j])
            break;
            }
        }
        cnt=cnt+z;
    }
    printf("%lld\n",cnt);
    }

}